{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "import math\n",
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "plt.style.use('seaborn-whitegrid')\n",
    "import statistics\n",
    "import pandas\n",
    "#import necessary packages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def cost_function(item, list_object):\n",
    "    sample_sum = 0\n",
    "    for element in list_object:\n",
    "        sample_sum = sample_sum + ((item - element)**2)/(len(list_object))\n",
    "    sample_sum = math.sqrt(sample_sum)\n",
    "    return sample_sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "#we write a cost function, J(theta), so we may determine the average error between the mean of a Globe cluster and the\n",
    "#observations pulled from a cube of Ice data --> the size of the cube should end up being 90 km x 90 km\n",
    "#the lat, long center for the Ice data cube and the Globe data cluster should be the same point ~approximately"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "ice_data = pandas.read_csv('elev_1.csv') #we use a CSV file of sample data for proof of concept"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>segment_id_beg</th>\n",
       "      <th>segment_id_end</th>\n",
       "      <th>longitude</th>\n",
       "      <th>latitude</th>\n",
       "      <th>h_te_best_fit</th>\n",
       "      <th>h_te_uncertainty</th>\n",
       "      <th>h_canopy</th>\n",
       "      <th>h_canopy_uncertainty</th>\n",
       "      <th>track_id</th>\n",
       "      <th>beam</th>\n",
       "      <th>file_name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>290744</td>\n",
       "      <td>290748</td>\n",
       "      <td>-172.978104</td>\n",
       "      <td>52.348576</td>\n",
       "      <td>4.502014</td>\n",
       "      <td>1.139743</td>\n",
       "      <td>18.417217</td>\n",
       "      <td>2.229614</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404010910_01300702_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>290749</td>\n",
       "      <td>290753</td>\n",
       "      <td>-172.978241</td>\n",
       "      <td>52.349472</td>\n",
       "      <td>1.471275</td>\n",
       "      <td>0.513425</td>\n",
       "      <td>20.925179</td>\n",
       "      <td>1.637308</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404010910_01300702_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>290754</td>\n",
       "      <td>290758</td>\n",
       "      <td>-172.978394</td>\n",
       "      <td>52.350368</td>\n",
       "      <td>7.502245</td>\n",
       "      <td>0.544397</td>\n",
       "      <td>14.111107</td>\n",
       "      <td>1.585246</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404010910_01300702_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>290759</td>\n",
       "      <td>290763</td>\n",
       "      <td>-172.978546</td>\n",
       "      <td>52.351261</td>\n",
       "      <td>7.733732</td>\n",
       "      <td>0.408622</td>\n",
       "      <td>18.597122</td>\n",
       "      <td>1.023427</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404010910_01300702_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>290764</td>\n",
       "      <td>290768</td>\n",
       "      <td>-172.978683</td>\n",
       "      <td>52.352158</td>\n",
       "      <td>5.962693</td>\n",
       "      <td>1.584672</td>\n",
       "      <td>15.630245</td>\n",
       "      <td>1.479247</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404010910_01300702_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>212241</th>\n",
       "      <td>2003982</td>\n",
       "      <td>2003986</td>\n",
       "      <td>169.323807</td>\n",
       "      <td>-0.578724</td>\n",
       "      <td>36.595955</td>\n",
       "      <td>0.356853</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt1l</td>\n",
       "      <td>processed_ATL08_20200404022923_01300714_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>212242</th>\n",
       "      <td>2003987</td>\n",
       "      <td>2003991</td>\n",
       "      <td>169.323715</td>\n",
       "      <td>-0.577821</td>\n",
       "      <td>36.000107</td>\n",
       "      <td>0.294612</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt1l</td>\n",
       "      <td>processed_ATL08_20200404022923_01300714_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>212243</th>\n",
       "      <td>2003992</td>\n",
       "      <td>2003996</td>\n",
       "      <td>169.323624</td>\n",
       "      <td>-0.576919</td>\n",
       "      <td>36.433630</td>\n",
       "      <td>0.341587</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt1l</td>\n",
       "      <td>processed_ATL08_20200404022923_01300714_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>212244</th>\n",
       "      <td>2003997</td>\n",
       "      <td>2004001</td>\n",
       "      <td>169.323547</td>\n",
       "      <td>-0.576016</td>\n",
       "      <td>35.889473</td>\n",
       "      <td>0.351560</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt1l</td>\n",
       "      <td>processed_ATL08_20200404022923_01300714_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>212245</th>\n",
       "      <td>2004002</td>\n",
       "      <td>2004005</td>\n",
       "      <td>169.323456</td>\n",
       "      <td>-0.575114</td>\n",
       "      <td>36.121883</td>\n",
       "      <td>0.473397</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt1l</td>\n",
       "      <td>processed_ATL08_20200404022923_01300714_003_01.h5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>212246 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        segment_id_beg  segment_id_end   longitude   latitude  h_te_best_fit  \\\n",
       "0               290744          290748 -172.978104  52.348576       4.502014   \n",
       "1               290749          290753 -172.978241  52.349472       1.471275   \n",
       "2               290754          290758 -172.978394  52.350368       7.502245   \n",
       "3               290759          290763 -172.978546  52.351261       7.733732   \n",
       "4               290764          290768 -172.978683  52.352158       5.962693   \n",
       "...                ...             ...         ...        ...            ...   \n",
       "212241         2003982         2003986  169.323807  -0.578724      36.595955   \n",
       "212242         2003987         2003991  169.323715  -0.577821      36.000107   \n",
       "212243         2003992         2003996  169.323624  -0.576919      36.433630   \n",
       "212244         2003997         2004001  169.323547  -0.576016      35.889473   \n",
       "212245         2004002         2004005  169.323456  -0.575114      36.121883   \n",
       "\n",
       "        h_te_uncertainty   h_canopy  h_canopy_uncertainty  track_id  beam  \\\n",
       "0               1.139743  18.417217              2.229614       130  gt3r   \n",
       "1               0.513425  20.925179              1.637308       130  gt3r   \n",
       "2               0.544397  14.111107              1.585246       130  gt3r   \n",
       "3               0.408622  18.597122              1.023427       130  gt3r   \n",
       "4               1.584672  15.630245              1.479247       130  gt3r   \n",
       "...                  ...        ...                   ...       ...   ...   \n",
       "212241          0.356853        NaN                   NaN       130  gt1l   \n",
       "212242          0.294612        NaN                   NaN       130  gt1l   \n",
       "212243          0.341587        NaN                   NaN       130  gt1l   \n",
       "212244          0.351560        NaN                   NaN       130  gt1l   \n",
       "212245          0.473397        NaN                   NaN       130  gt1l   \n",
       "\n",
       "                                                file_name  \n",
       "0       processed_ATL08_20200404010910_01300702_003_01.h5  \n",
       "1       processed_ATL08_20200404010910_01300702_003_01.h5  \n",
       "2       processed_ATL08_20200404010910_01300702_003_01.h5  \n",
       "3       processed_ATL08_20200404010910_01300702_003_01.h5  \n",
       "4       processed_ATL08_20200404010910_01300702_003_01.h5  \n",
       "...                                                   ...  \n",
       "212241  processed_ATL08_20200404022923_01300714_003_01.h5  \n",
       "212242  processed_ATL08_20200404022923_01300714_003_01.h5  \n",
       "212243  processed_ATL08_20200404022923_01300714_003_01.h5  \n",
       "212244  processed_ATL08_20200404022923_01300714_003_01.h5  \n",
       "212245  processed_ATL08_20200404022923_01300714_003_01.h5  \n",
       "\n",
       "[212246 rows x 11 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ice_data #pre-edited data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "ice_data = ice_data[ice_data['h_canopy']> 0] #we do not want any None values for tree height included"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>segment_id_beg</th>\n",
       "      <th>segment_id_end</th>\n",
       "      <th>longitude</th>\n",
       "      <th>latitude</th>\n",
       "      <th>h_te_best_fit</th>\n",
       "      <th>h_te_uncertainty</th>\n",
       "      <th>h_canopy</th>\n",
       "      <th>h_canopy_uncertainty</th>\n",
       "      <th>track_id</th>\n",
       "      <th>beam</th>\n",
       "      <th>file_name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>290744</td>\n",
       "      <td>290748</td>\n",
       "      <td>-172.978104</td>\n",
       "      <td>52.348576</td>\n",
       "      <td>4.502014</td>\n",
       "      <td>1.139743</td>\n",
       "      <td>18.417217</td>\n",
       "      <td>2.229614</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404010910_01300702_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>290749</td>\n",
       "      <td>290753</td>\n",
       "      <td>-172.978241</td>\n",
       "      <td>52.349472</td>\n",
       "      <td>1.471275</td>\n",
       "      <td>0.513425</td>\n",
       "      <td>20.925179</td>\n",
       "      <td>1.637308</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404010910_01300702_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>290754</td>\n",
       "      <td>290758</td>\n",
       "      <td>-172.978394</td>\n",
       "      <td>52.350368</td>\n",
       "      <td>7.502245</td>\n",
       "      <td>0.544397</td>\n",
       "      <td>14.111107</td>\n",
       "      <td>1.585246</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404010910_01300702_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>290759</td>\n",
       "      <td>290763</td>\n",
       "      <td>-172.978546</td>\n",
       "      <td>52.351261</td>\n",
       "      <td>7.733732</td>\n",
       "      <td>0.408622</td>\n",
       "      <td>18.597122</td>\n",
       "      <td>1.023427</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404010910_01300702_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>290764</td>\n",
       "      <td>290768</td>\n",
       "      <td>-172.978683</td>\n",
       "      <td>52.352158</td>\n",
       "      <td>5.962693</td>\n",
       "      <td>1.584672</td>\n",
       "      <td>15.630245</td>\n",
       "      <td>1.479247</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404010910_01300702_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>211564</th>\n",
       "      <td>2003644</td>\n",
       "      <td>2003648</td>\n",
       "      <td>169.330399</td>\n",
       "      <td>-0.639653</td>\n",
       "      <td>19.499273</td>\n",
       "      <td>NaN</td>\n",
       "      <td>43.147210</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt1r</td>\n",
       "      <td>processed_ATL08_20200404022923_01300714_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>211565</th>\n",
       "      <td>2003649</td>\n",
       "      <td>2003651</td>\n",
       "      <td>169.330322</td>\n",
       "      <td>-0.638749</td>\n",
       "      <td>22.489426</td>\n",
       "      <td>NaN</td>\n",
       "      <td>38.992638</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt1r</td>\n",
       "      <td>processed_ATL08_20200404022923_01300714_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>211566</th>\n",
       "      <td>2003695</td>\n",
       "      <td>2003699</td>\n",
       "      <td>169.329544</td>\n",
       "      <td>-0.630445</td>\n",
       "      <td>10.447918</td>\n",
       "      <td>NaN</td>\n",
       "      <td>46.605175</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt1r</td>\n",
       "      <td>processed_ATL08_20200404022923_01300714_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>211567</th>\n",
       "      <td>2003701</td>\n",
       "      <td>2003704</td>\n",
       "      <td>169.329453</td>\n",
       "      <td>-0.629361</td>\n",
       "      <td>15.458924</td>\n",
       "      <td>NaN</td>\n",
       "      <td>44.837128</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt1r</td>\n",
       "      <td>processed_ATL08_20200404022923_01300714_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>211568</th>\n",
       "      <td>2003705</td>\n",
       "      <td>2003709</td>\n",
       "      <td>169.329391</td>\n",
       "      <td>-0.628639</td>\n",
       "      <td>28.159456</td>\n",
       "      <td>2.114030</td>\n",
       "      <td>28.657064</td>\n",
       "      <td>3.643278</td>\n",
       "      <td>130</td>\n",
       "      <td>gt1r</td>\n",
       "      <td>processed_ATL08_20200404022923_01300714_003_01.h5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>54805 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        segment_id_beg  segment_id_end   longitude   latitude  h_te_best_fit  \\\n",
       "0               290744          290748 -172.978104  52.348576       4.502014   \n",
       "1               290749          290753 -172.978241  52.349472       1.471275   \n",
       "2               290754          290758 -172.978394  52.350368       7.502245   \n",
       "3               290759          290763 -172.978546  52.351261       7.733732   \n",
       "4               290764          290768 -172.978683  52.352158       5.962693   \n",
       "...                ...             ...         ...        ...            ...   \n",
       "211564         2003644         2003648  169.330399  -0.639653      19.499273   \n",
       "211565         2003649         2003651  169.330322  -0.638749      22.489426   \n",
       "211566         2003695         2003699  169.329544  -0.630445      10.447918   \n",
       "211567         2003701         2003704  169.329453  -0.629361      15.458924   \n",
       "211568         2003705         2003709  169.329391  -0.628639      28.159456   \n",
       "\n",
       "        h_te_uncertainty   h_canopy  h_canopy_uncertainty  track_id  beam  \\\n",
       "0               1.139743  18.417217              2.229614       130  gt3r   \n",
       "1               0.513425  20.925179              1.637308       130  gt3r   \n",
       "2               0.544397  14.111107              1.585246       130  gt3r   \n",
       "3               0.408622  18.597122              1.023427       130  gt3r   \n",
       "4               1.584672  15.630245              1.479247       130  gt3r   \n",
       "...                  ...        ...                   ...       ...   ...   \n",
       "211564               NaN  43.147210                   NaN       130  gt1r   \n",
       "211565               NaN  38.992638                   NaN       130  gt1r   \n",
       "211566               NaN  46.605175                   NaN       130  gt1r   \n",
       "211567               NaN  44.837128                   NaN       130  gt1r   \n",
       "211568          2.114030  28.657064              3.643278       130  gt1r   \n",
       "\n",
       "                                                file_name  \n",
       "0       processed_ATL08_20200404010910_01300702_003_01.h5  \n",
       "1       processed_ATL08_20200404010910_01300702_003_01.h5  \n",
       "2       processed_ATL08_20200404010910_01300702_003_01.h5  \n",
       "3       processed_ATL08_20200404010910_01300702_003_01.h5  \n",
       "4       processed_ATL08_20200404010910_01300702_003_01.h5  \n",
       "...                                                   ...  \n",
       "211564  processed_ATL08_20200404022923_01300714_003_01.h5  \n",
       "211565  processed_ATL08_20200404022923_01300714_003_01.h5  \n",
       "211566  processed_ATL08_20200404022923_01300714_003_01.h5  \n",
       "211567  processed_ATL08_20200404022923_01300714_003_01.h5  \n",
       "211568  processed_ATL08_20200404022923_01300714_003_01.h5  \n",
       "\n",
       "[54805 rows x 11 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ice_data #post-edited data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "ice_segment = ice_data[ice_data['latitude'] > 36]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "ice_segment = ice_segment[ice_segment['latitude'] < 40]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>segment_id_beg</th>\n",
       "      <th>segment_id_end</th>\n",
       "      <th>longitude</th>\n",
       "      <th>latitude</th>\n",
       "      <th>h_te_best_fit</th>\n",
       "      <th>h_te_uncertainty</th>\n",
       "      <th>h_canopy</th>\n",
       "      <th>h_canopy_uncertainty</th>\n",
       "      <th>track_id</th>\n",
       "      <th>beam</th>\n",
       "      <th>file_name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>54043</th>\n",
       "      <td>798573</td>\n",
       "      <td>798577</td>\n",
       "      <td>5.028290</td>\n",
       "      <td>36.633396</td>\n",
       "      <td>613.985050</td>\n",
       "      <td>26.909111</td>\n",
       "      <td>9.423950</td>\n",
       "      <td>18.903818</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404013340_01300706_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54042</th>\n",
       "      <td>798568</td>\n",
       "      <td>798572</td>\n",
       "      <td>5.028398</td>\n",
       "      <td>36.634296</td>\n",
       "      <td>606.298160</td>\n",
       "      <td>9.618637</td>\n",
       "      <td>4.944763</td>\n",
       "      <td>9.116385</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404013340_01300706_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54041</th>\n",
       "      <td>798563</td>\n",
       "      <td>798567</td>\n",
       "      <td>5.028508</td>\n",
       "      <td>36.635197</td>\n",
       "      <td>640.759600</td>\n",
       "      <td>16.264473</td>\n",
       "      <td>5.619934</td>\n",
       "      <td>8.737176</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404013340_01300706_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54040</th>\n",
       "      <td>798558</td>\n",
       "      <td>798562</td>\n",
       "      <td>5.028612</td>\n",
       "      <td>36.636093</td>\n",
       "      <td>628.668600</td>\n",
       "      <td>5.301216</td>\n",
       "      <td>5.677063</td>\n",
       "      <td>4.579609</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404013340_01300706_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54039</th>\n",
       "      <td>798553</td>\n",
       "      <td>798557</td>\n",
       "      <td>5.028717</td>\n",
       "      <td>36.636993</td>\n",
       "      <td>601.415100</td>\n",
       "      <td>7.970351</td>\n",
       "      <td>5.344299</td>\n",
       "      <td>7.294723</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404013340_01300706_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53977</th>\n",
       "      <td>797875</td>\n",
       "      <td>797879</td>\n",
       "      <td>5.043192</td>\n",
       "      <td>36.758915</td>\n",
       "      <td>88.387596</td>\n",
       "      <td>0.365439</td>\n",
       "      <td>18.281510</td>\n",
       "      <td>0.352817</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404013340_01300706_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53976</th>\n",
       "      <td>797870</td>\n",
       "      <td>797874</td>\n",
       "      <td>5.043303</td>\n",
       "      <td>36.759811</td>\n",
       "      <td>108.999540</td>\n",
       "      <td>1.138490</td>\n",
       "      <td>11.220581</td>\n",
       "      <td>0.695925</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404013340_01300706_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53973</th>\n",
       "      <td>797768</td>\n",
       "      <td>797772</td>\n",
       "      <td>5.045497</td>\n",
       "      <td>36.778152</td>\n",
       "      <td>131.465820</td>\n",
       "      <td>NaN</td>\n",
       "      <td>17.380615</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404013340_01300706_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53971</th>\n",
       "      <td>797758</td>\n",
       "      <td>797762</td>\n",
       "      <td>5.045716</td>\n",
       "      <td>36.779949</td>\n",
       "      <td>106.475640</td>\n",
       "      <td>NaN</td>\n",
       "      <td>65.842790</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>gt3r</td>\n",
       "      <td>processed_ATL08_20200404013340_01300706_003_01.h5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91594</th>\n",
       "      <td>796601</td>\n",
       "      <td>796605</td>\n",
       "      <td>5.106318</td>\n",
       "      <td>36.985233</td>\n",
       "      <td>41.968014</td>\n",
       "      <td>0.232778</td>\n",
       "      <td>108.600030</td>\n",
       "      <td>0.757321</td>\n",
       "      <td>130</td>\n",
       "      <td>gt2r</td>\n",
       "      <td>processed_ATL08_20200404013340_01300706_003_01.h5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>204 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       segment_id_beg  segment_id_end  longitude   latitude  h_te_best_fit  \\\n",
       "54043          798573          798577   5.028290  36.633396     613.985050   \n",
       "54042          798568          798572   5.028398  36.634296     606.298160   \n",
       "54041          798563          798567   5.028508  36.635197     640.759600   \n",
       "54040          798558          798562   5.028612  36.636093     628.668600   \n",
       "54039          798553          798557   5.028717  36.636993     601.415100   \n",
       "...               ...             ...        ...        ...            ...   \n",
       "53977          797875          797879   5.043192  36.758915      88.387596   \n",
       "53976          797870          797874   5.043303  36.759811     108.999540   \n",
       "53973          797768          797772   5.045497  36.778152     131.465820   \n",
       "53971          797758          797762   5.045716  36.779949     106.475640   \n",
       "91594          796601          796605   5.106318  36.985233      41.968014   \n",
       "\n",
       "       h_te_uncertainty    h_canopy  h_canopy_uncertainty  track_id  beam  \\\n",
       "54043         26.909111    9.423950             18.903818       130  gt3r   \n",
       "54042          9.618637    4.944763              9.116385       130  gt3r   \n",
       "54041         16.264473    5.619934              8.737176       130  gt3r   \n",
       "54040          5.301216    5.677063              4.579609       130  gt3r   \n",
       "54039          7.970351    5.344299              7.294723       130  gt3r   \n",
       "...                 ...         ...                   ...       ...   ...   \n",
       "53977          0.365439   18.281510              0.352817       130  gt3r   \n",
       "53976          1.138490   11.220581              0.695925       130  gt3r   \n",
       "53973               NaN   17.380615                   NaN       130  gt3r   \n",
       "53971               NaN   65.842790                   NaN       130  gt3r   \n",
       "91594          0.232778  108.600030              0.757321       130  gt2r   \n",
       "\n",
       "                                               file_name  \n",
       "54043  processed_ATL08_20200404013340_01300706_003_01.h5  \n",
       "54042  processed_ATL08_20200404013340_01300706_003_01.h5  \n",
       "54041  processed_ATL08_20200404013340_01300706_003_01.h5  \n",
       "54040  processed_ATL08_20200404013340_01300706_003_01.h5  \n",
       "54039  processed_ATL08_20200404013340_01300706_003_01.h5  \n",
       "...                                                  ...  \n",
       "53977  processed_ATL08_20200404013340_01300706_003_01.h5  \n",
       "53976  processed_ATL08_20200404013340_01300706_003_01.h5  \n",
       "53973  processed_ATL08_20200404013340_01300706_003_01.h5  \n",
       "53971  processed_ATL08_20200404013340_01300706_003_01.h5  \n",
       "91594  processed_ATL08_20200404013340_01300706_003_01.h5  \n",
       "\n",
       "[204 rows x 11 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ice_segment.sort_values(by = 'latitude')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "#for proof of concept, we choose a slice of data between 36-40 degrees latitude, with no longitudal bounds\n",
    "# we will make the cube of observation much smaller, once we delve into the actual data files --> this is simply\n",
    "#a demonstration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "ice_height = ice_segment['h_canopy'].values.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "#ice_height creates a list of tree height canopies that fall within the given latitudal constraint function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203]\n"
     ]
    }
   ],
   "source": [
    "dummy_list = []\n",
    "for i in range(len(ice_height)):\n",
    "    dummy_list.append(i)\n",
    "print(dummy_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "#create a sample list so we can plot the ice_height data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXEAAAD0CAYAAABtjRZ7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh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8BknU04NbitX0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(dummy_list, ice_height, 'o', color='black');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "#as we can observe via the scatter plot, there are several outliers in the data set\n",
    "#we will need to write a function to get rid of the outliers, so our error function will best reflect\n",
    "#the central tendencies and differences between the two data sets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "def outlier(sample_list):\n",
    "    mean = statistics.mean(sample_list)\n",
    "    stdev = statistics.stdev(sample_list)\n",
    "    max_outlier = mean + 3*stdev\n",
    "    min_outlier = mean - 3*stdev\n",
    "    while max(sample_list) > max_outlier:\n",
    "        sample_list.remove(max(sample_list))\n",
    "    while min(sample_list) < min_outlier:\n",
    "        sample_list.remove(min(sample_list))\n",
    "    return sample_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "#the above function does the following:\n",
    "#given a list as input, while the max or min values of the list exceed 3 standard deviations from the mean,\n",
    "#remove the max value --> this will ensure a cost function error product which is less impacted by \n",
    "#outliers in the ICE data set"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "ice_height = outlier(ice_height)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "#let's pick a sample few sample means from the cluster data collected previously:\n",
    "mean_list = [10,13,15,16]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6.126972092730667\n",
      "6.10324210710648\n",
      "6.859743606471674\n",
      "7.41345677877835\n"
     ]
    }
   ],
   "source": [
    "for item in mean_list:\n",
    "    print(cost_function(item, ice_height))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Based on these cluster sample, it seems the general error is around ~6 meters. Once we nail down much better / \n",
    "#more comprehensive ice data, this error product should reduce further. However, not a bad initial error"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
